document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    
    // admob
    if (window.plugins && window.plugins.AdMob) {
        var admob_android_key = 'ca-app-pub-6465819007267041/3067154813'; // tictactoe bottom 
        //var adId = (navigator.userAgent.indexOf('Android') >= 0) ? admob_android_key : admob_ios_key;
        var adId = admob_android_key;
        var am = window.plugins.AdMob;

        am.createBannerView(
                {
                    'publisherId': adId,
                    'adSize': am.AD_SIZE.BANNER,
                    'bannerAtTop': false
                },
                function() {
                    am.requestAd(
                            {'isTesting': false},
                    function() {
                        am.showAd(true);
                    },
                            function() {
                                console.log('TicTacToe ERRPR : failed to request ad');
                            }
                    );
                },
                function() {
                    console.log('TicTacToe ERROR : failed to create banner view');
                }
        );
    } else {
        console.log('TicTacToe ERROR : AdMob plugin not available/ready.');
    }

    // when all is done, execute bootstrap angular application
    angular.bootstrap(document, ['myApp']);
    
    setTimeout(function() {
        navigator.splashscreen.hide();
    }, 1000);
}
